Expression: DateTime Functions
DateTime functions are provided to manipulate FastStats datetime fields.
TimeDiff
|
TimeDiff calculates the difference between 2 DateTimes, measured in the specified units. If no units are specified, seconds are used.
TimeDiff([DateTime1],[DateTime2],"Hours")
If only 1 DateTime is specified, it will compare to the current date and time:
|
TimeHour
|
TimeHour( DateTime ). Calculates the hour of day of a DateTime
TimeHour([Communication Date])
e.g. 17-06-2010 16:43:24 returns 16
|
TimeMinute |
TimeMinute( DateTime ). Calculates the minute of hour of a DateTime
TimeMinute([Communication Date])
e.g. 17-06-2010 16:43:24 returns 43
|
TimeSecond |
TimeSecond( DateTime ). Calculates the second of minute of a DateTime
TimeSecond([Communication Date])
e.g. 17-06-2010 16:43:24 returns 24
|
MakeDateTime
|
MakeDateTime creates a DateTime from constituent parts
MakeDateTime(Year,Month,Day,Hour,Minute,Second)
e.g. 17-06-2010 16:43:24
|
SelectedHours
|
SelectedHours calculates the number of hours between two date time values
SelectedHours(datetime1,datetime2,day_pattern,starttime,endtime)
Example:
In the above example the first date-time is a variable and the second is constructed using the MakeDateTime function. The day pattern is made up of 1 and 0 to represent which days of the week to consider (Monday to Sunday). The start and end times indicate the hours within a day to consider. Therefore in this example we are only considering the hours in a working week, Monday to Friday between 8.30am to 5.30pm (24 hour time display).
|
TimeNow |
TimeNow returns the current DateTime shifted by a specified number of seconds
TimeNow(300)
The above example will return the date for today and the time 300 seconds in advance of the current time when the request to process is started. e.g. If the date and time were 16/05/2018 11:10:25, the result returned would be 16/05/2018 11:15:25.
|
FormatTime |
FormatTime takes the numeric value in the parameter and formats it as an elapsed time string in seconds
FormatTime(230)
The above example will return 3 minutes and 50 seconds (230 seconds) as 00:03:50
|
BuildDateTime |
BuildDateTime() - returns the build date and time.
BuildDateTime(Number) - returns the build date and time and optionally adds the "Number" in seconds. For example: BuildDateTime(3600) - returns the datetime 1 hour after the build datetime.
|
DateTimeShift |
DateTimeShift(DateTime, Number, "Units") returns a datetime by incrementing the given datetime by the defined number of units. Valid "Units" are years, quarters, months, weeks, days, hours, minutes, or seconds.
DateTimeShift([Order DateTime], 12, "Hours")
The above example will return the datetime 12 hours after the order datetime.
|
AgeHours |
AgeHours(DateTime) returns the age in hours of the datetime value.
AgeHours([Order DateTime])
The above example returns the number of hours ago that the order datetime was.
|
AgeMinutes |
AgeMinutes(DateTime) returns the age in minutes of the datetime value.
AgeMinutes([Order DateTime])
The above example returns the number of minutes ago that the order datetime was.
|
AgeSeconds |
AgeSeconds(DateTime) returns the age in seconds of the datetime value.
AgeSeconds([Order DateTime])
The above example returns the number of seconds ago the order datetime was.
|
DateTimeStart |
DateTimeStart(DateTime, Number, "Units") returns a datetime by shifting a datetime to the start of the unit and then offsetting it by the defined number of units.
Valid "Units" are years, quarters, months, weeks, days, hours, minutes, or seconds.
DateTimeStart([Order DateTime], 0, "Hours")
The above example shifts the order datetime to the start of this hour.
|
DateTimeEnd |
DateTimeEnd(DateTime, Number, "Units") returns a datetime by shifting a datetime to the end of the unit and then offsetting it by the defined number of the units.
Valid "Units" are years, quarters, months, weeks, days, hours, minutes, or seconds.
DateTimeEnd([Order DateTime], 0, "Hours")
The above example shifts the order datetime to the end of this hour.
|
DateTimeConvert |
DateTimeConvert(DateTime, Source Zone, Destination Zone) converts a datetime from one timezone to another.
e.g. DateTimeConvert([Communication DateTime], "UTC", "Australia/Sydney")
The above example shifts the communication datetime specified in UTC to Australia/Sydney local time.
For further information, including a list of valid timezones, see Expression: Considerations when working with the DateTimeConvert function
|
FinancialDateTimeStart |
FinancialDateTimeStart(DateTime, Offset, Units) returns a datetime by shifting the datetime to the start of the financial unit and then offsetting it by the defined number of units.
Valid "Units" are years, quarters, or months.
e.g. FinancialDateTimeStart([Order DateTime], 0, "Years")
The above example returns the start of the financial year in which the order datetime falls.
|
FinancialDateTimeEnd |
FinancialDateTimeEnd(DateTime, Offset, Units) returns a datetime by shifting the datetime to the end of the financial unit and then offsetting it by defined number of units.
Valid "Units" are years, quarters, or months.
FinancialDateTimeEnd([Order DateTime], 0, "Years")
The above example returns the end of the financial year in which the order datetime falls.
|
DateTimeToNumber |
DateTimeToNumber(DateTime)
Converts the date time to a number in the form YYYYMMDDHHMMSS.
e.g. DateTimeToNumber([Order DateTime]) - returns the order datetime as a numeric.
|